# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from fastapi import APIRouter, Request, Depends
from hypertext import R, response_json, PagingResult
from apps.api.schemas.agent.robot import journal_schema as schema
from apps.api.service.agent.robot.journal_service import RobotJournalService

router = APIRouter(prefix="/journal", tags=["智能体日志接口"])


@router.get("/records", summary="对话日志", response_model=R[PagingResult[schema.RobotJournalListVo]])
@response_json
async def records(request: Request, params: schema.RobotJournalSearchIn = Depends()):
    user_id: int = int(request.state.user_id)
    return await RobotJournalService.records(params, user_id)


@router.post("/corrects", summary="对话修正", response_model=R)
@response_json
async def corrects(request: Request, params: schema.RobotJournalCorrectsIn):
    user_id: int = int(request.state.user_id)
    return await RobotJournalService.corrects(user_id, params)


@router.post("/delete", summary="对话删除", response_model=R)
@response_json
async def delete(request: Request, params: schema.RobotJournalDeleteIn):
    user_id: int = int(request.state.user_id)
    await RobotJournalService.delete(user_id, params.bot, params.ids)
